package com.gin.supermarket_inventory_system.inventory.dto.form.receipt;

import com.gin.database.validation.EntityId;
import com.gin.supermarket_inventory_system.inventory.entity.InventoryReceiptDetailPo;
import com.gin.supermarket_inventory_system.inventory.service.InventoryService;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.annotation.Validated;

/**
 * 添加库存数量变动详情
 * @since : 2023/10/11 15:02
 * @author : ginstone
 * @version : v1.0.0
 **/
@Getter
@Setter
@Schema(description = "表单对象:添加库存盘点详情")
@Validated
public class InventoryReceiptCheckDetailForm {
    @Schema(description = "库存id")
    @EntityId(service = InventoryService.class)
    @NotNull
    long inventoryId;

    @Schema(description = "盘点数量")
    @NotNull
    @Min(0)
    int amount;

    @Schema(description = "备注")
    String remark;

    //todo 进货和退货时需要提供价格

    public InventoryReceiptDetailPo toPo() {
        final InventoryReceiptDetailPo po = new InventoryReceiptDetailPo();
        BeanUtils.copyProperties(this, po);
        return po;
    }


}